/*
 * @Description: 异步串行钩子
 * @Author: wangqi
 * @Date: 2021-04-18 11:26:38
 * @LastEditTime: 2021-04-18 11:40:32
 */

let { AsyncSeriesHook } = require('tapable');


class Lesson {
    constructor() {
        this.hook = {
            arch: new AsyncSeriesHook(['name']),
        }
    }

    tap() {
        this.hook.arch.tapAsync('node', (name, cb) => {
            setTimeout(() => {
                console.log("node", name);
                cb();
            }, 1000);
        });

        this.hook.arch.tapAsync('vue', (name, cb) => {
            setTimeout(() => {
                console.log("vue", name);
                cb();
            }, 1000);
        });
    }

    start() {
        this.hook.arch.callAsync('wq1', function () {
            console.log('end')
        })
    }
}

let lesson = new Lesson();

lesson.tap();
lesson.start();





